<template lang="">
    <div>
        绑定账号<br>
        <input type="text" v-model='username'>
        <button @click='bind'>绑定</button>
    </div>
</template>
<script>
export default {
    data(){
        return{
            username:''
        }
    },
    methods: {
        bind(){
            var uid = this.$route.query.uid
            var token = this.$route.query.token
            //调用绑定接口,uid,token
            this.axios.post('users/bind/',{'uid':uid,'token':token,'username':this.username}).then(res=>{
                var user = res.data.users
                localStorage.setItem('userid',user.id)
                localStorage.setItem('username',user.username)
                this.$router.push({'name':'Home'})
            })
        }
    },

    created(){
        var id = this.$route.query.id
        var username = this.$route.query.username
        if(id){
            localStorage.setItem('userid',id)
            localStorage.setItem('username',username)
            this.$router.push({'name':'Home'})
        }
    },
}
</script>
<style lang="">
    
</style>